1 /*
2 * $Header: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/NodeDescriptor.java,v 1.1 2002/06/10 17:53:34 jstrachan Exp $
3 * $Revision: 1.1 $
4 * $Date: 2002/06/10 17:53:34 $
5 *
6 * ====================================================================
7 *
8 * The Apache Software License, Version 1.1
9 *
10 * Copyright (c) 1999-2002 The Apache Software Foundation. All rights
11 * reserved.
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 *
17 * 1. Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 *
20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in
22 * the documentation and/or other materials provided with the
23 * distribution.
24 *
25 * 3. The end-user documentation included with the redistribution, if
26 * any, must include the following acknowlegement:
27 * "This product includes software developed by the
28 * Apache Software Foundation (http://www.apache.org/)."
29 * Alternately, this acknowlegement may appear in the software itself,
30 * if and wherever such third-party acknowlegements normally appear.
31 *
32 * 4. The names "The Jakarta Project", "Commons", and "Apache Software
33 * Foundation" must not be used to endorse or promote products derived
34 * from this software without prior written permission. For written
35 * permission, please contact apache@apache.org.
36 *
37 * 5. Products derived from this software may not be called "Apache"
38 * nor may "Apache" appear in their names without prior written
39 * permission of the Apache Group.
40 *
41 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
42 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
43 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
44 * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
45 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
46 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
47 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
48 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
49 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
50 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
51 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
52 * SUCH DAMAGE.
53 * ====================================================================
54 *
55 * This software consists of voluntary contributions made by many
56 * individuals on behalf of the Apache Software Foundation. For more
57 * information on the Apache Software Foundation, please see
58 * <http://www.apache.org/>.
59 *
60 * $Id: NodeDescriptor.java,v 1.1 2002/06/10 17:53:34 jstrachan Exp $
61 */
62 package org.apache.commons.betwixt;
63
64 import org.apache.commons.betwixt.expression.Expression;
65 import org.apache.commons.betwixt.expression.Updater;
66
67 /*** <p> Common superclass for <code>ElementDescriptor</code> and <code>AttributeDescriptor</code>.</p>
68 *
69 * <p> Nodes can have just a local name
70 * or they can have a local name, qualified name and a namespace uri.</p>
71 *
72 * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
73 * @version $Revision: 1.1 $
74 */
75 public class NodeDescriptor {
76
77 /*** The local name of this node without any namespace prefix */
78 private String localName;
79 private String qualifiedName;
80 /*** The namespace URI of this node */
81 private String uri = "";
82 /*** the expression used to evaluate the text value of this node */
83 private Expression textExpression;
84 /*** the updater used to update the current bean from the text value of this node */
85 private Updater updater;
86 /*** The property expression to which this node refers to, or null if it is just a constant */
87 private String propertyName;
88 /*** the property type associated with this node, if any */
89 private Class propertyType;
90 /*** the singular property type (i.e. the type ignoring the Collection or Array */
91 private Class singularPropertyType;
92
93
94 /*** Base constructor */
95 public NodeDescriptor() {
96 }
97
98 /*** Creates a NodeDescriptor with no namespace URI or prefix */
99 public NodeDescriptor(String localName) {
100 this.localName = localName;
101 this.qualifiedName = localName;
102 }
103
104
105 /*** Creates a NodeDescriptor with namespace URI and qualified name */
106 public NodeDescriptor(String localName, String qualifiedName, String uri) {
107 this.localName = localName;
108 this.qualifiedName = qualifiedName;
109 this.uri = uri;
110 }
111
112 /*** Returns the local name, excluding any namespace prefix
113 */
114 public String getLocalName() {
115 return localName;
116 }
117
118 /*** Sets the local name
119 */
120 public void setLocalName(String localName) {
121 this.localName = localName;
122 }
123
124 /*** Returns the qualified name, including any namespace prefix
125 */
126 public String getQualifiedName() {
127 if ( qualifiedName == null ) {
128 qualifiedName = localName;
129 }
130 return qualifiedName;
131 }
132
133 /*** Sets the qualified name
134 */
135 public void setQualifiedName(String qualifiedName) {
136 this.qualifiedName = qualifiedName;
137 }
138
139 /*** Returns the namespace URI that this node belongs to or "" if there is no namespace defined */
140 public String getURI() {
141 return uri;
142 }
143
144
145 /*** Sets the namespace URI that this node belongs to.
146 */
147 public void setURI(String uri) {
148 if ( uri == null ) {
149 throw new IllegalArgumentException(
150 "The namespace URI cannot be null. "
151 + "No namespace URI is specified with the empty string"
152 );
153 }
154 this.uri = uri;
155 }
156
157 /*** Returns the expression used to evaluate the text value of this node */
158 public Expression getTextExpression() {
159 return textExpression;
160 }
161
162 /*** Sets the expression used to evaluate the text value of this node */
163 public void setTextExpression(Expression textExpression) {
164 this.textExpression = textExpression;
165 }
166
167 /*** the updater used to update the current bean from the text value of this node */
168 public Updater getUpdater() {
169 return updater;
170 }
171
172 /*** sets the updater used to update the current bean from the text value of this node */
173 public void setUpdater(Updater updater) {
174 this.updater = updater;
175 }
176
177 /*** @return the property type associated with this node, if any */
178 public Class getPropertyType() {
179 return propertyType;
180 }
181
182 /*** Sets the property type associated with this node, if any */
183 public void setPropertyType(Class propertyType) {
184 this.propertyType = propertyType;
185 }
186
187
188 /*** @return the property expression to which this node refers to, or null if it is just a constant */
189 public String getPropertyName() {
190 return propertyName;
191 }
192
193 /*** Sets the property expression to which this node refers to, or null if it is just a constant */
194 public void setPropertyName(String propertyName) {
195 this.propertyName = propertyName;
196 }
197
198 /***
199 * @return if this property is a 1-N relationship then this returns the type
200 * of a single property value.
201 */
202 public Class getSingularPropertyType() {
203 if ( singularPropertyType == null ) {
204 return getPropertyType();
205 }
206 return singularPropertyType;
207 }
208
209 /***
210 * Sets the singular property type (i.e. the type ignoring the Collection or Array
211 */
212 public void setSingularPropertyType(Class singularPropertyType) {
213 this.singularPropertyType = singularPropertyType;
214 }
215
216 }
This page was automatically generated by Maven